filename = ["20200324__{}GHz_301pts_avg 10counts_-2dBm_withAMP_IFBW10_S21_Pt-Py_Volt.txt".format(i) for i in range(7,12)]
filename
for file in filename:
with open(file, 'r') as f:
modified_string = ""
for line in f:
if line[0]!="#":
modified_string = modified_string + line
with open(file[:-4]+"_modified"+".txt", "w") as g:
g.write(modified_string)
filename_power = ["20200324__7GHz_301pts_avg 10counts_{}dBm_withAMP_IFBW10_S21_Pt-Py_Volt.txt".format(i) for i in range(2,-18,-2)]
for file in filename_power:
with open(file, 'r') as f:
modified_string = ""
for line in f:
if line[0]!="#":
modified_string = modified_string + line
with open(file[:-4]+"_modified"+".txt", "w") as g:
g.write(modified_string)
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import lmfit
filename = ["20200324__{}GHz_301pts_avg 10counts_-2dBm_withAMP_IFBW10_S21_Pt-Py_Volt_modified.txt".format(i) for i in range(7,12)]
filename[1].split("__")[1].split("GHz")[0]
for file in filename:
data = pd.read_csv(file, sep='\t')
x = data["Field (G)"].values
y_x = data["Voltage X (V)"].values * 1E6
y_y = data["Volatge Y (V)"].values * 1E6
y_R = data["Voltage R (V)"].values * 1E6
plt.figure(dpi=150)
plt.plot(x,y_x, label= "X")
plt.plot(x,y_y, label="Y")
plt.plot(x,y_R, label="R")
plt.xlabel("Field (G)")
plt.ylabel(r"Voltage ($\mu$V)")
plt.title("Freq. "+ file.split("__")[1].split("GHz")[0] + " GHz")
plt.legend()
plt.savefig("Freq_"+ file.split("__")[1].split("GHz")[0] +".png", dpi = 300)
from scipy.signal import find_peaks
def residual(params, x, y):
const = params['const'].value
slope = params['slope'].value
c = params['c'].value
A = params['A'].value
B = params['B'].value
T = params['T'].value
Hfmr = params['Hfmr'].value
model = const + slope * (x-c) + A* T**2/((x-Hfmr)**2+T**2) - B * 2*T*(x-Hfmr)/((x-Hfmr)**2+T**2)
return np.sqrt((y-model)**2)
def fit_data(params, x):
const = params['const'].value
slope = params['slope'].value
c = params['c'].value
A = params['A'].value
B = params['B'].value
T = params['T'].value
Hfmr = params['Hfmr'].value
model = const + slope * (x-c) + A* T**2/((x-Hfmr)**2+T**2) - B * 2*T*(x-Hfmr)/((x-Hfmr)**2+T**2)
return model
linewidth = []
V_ISHE = []
V_AHE = []
H_FMR = []
for file in filename:
data = pd.read_csv(file, sep='\t')
x = data["Field (G)"].values
y = data["Voltage R (V)"].values * 1E6
peaks, _= find_peaks(y, height=0.2)
params = lmfit.Parameters()
params.add('const', value= 0)
params.add('slope', value=0)
params.add('c', value=0)
params.add('A',value=0)
params.add('B',value=0)
params.add('T', value=50)
params.add('Hfmr', value=x[peaks][0])
out = lmfit.minimize(residual, params, args=(x,y))
plt.figure(dpi=150)
plt.plot(x,y, label = "original Voltage R")
plt.plot(x, fit_data(out.params,x), label = "fitting data")
plt.text(10,0.8,r"V$_{ISHE}$: " + "{:.3f}".format(out.params["A"].value))
V_ISHE.append(out.params["A"].value)
plt.text(10,0.6,r"V$_{AHE}$: " + "{:.3f}".format(out.params["B"].value))
V_AHE.append(out.params["B"].value)
plt.text(10,0.4,r"H$_{FMR}$: "+"{:.3f}".format(out.params["Hfmr"].value))
H_FMR.append(out.params["Hfmr"].value)
plt.text(10,0.2,r"Linewidth: {:.3f}".format(out.params["T"].value))
linewidth.append(out.params["T"].value)
plt.ylim(-0.1,2)
plt.legend()
plt.xlabel("Field (G)")
plt.ylabel(r"Voltage ($\mu$V)")
plt.title("Freq. "+ file.split("__")[1].split("GHz")[0] + " GHz")
plt.savefig("Freq_"+ file.split("__")[1].split("GHz")[0] + "GHz_fitting.png",dpi=300)
plt.figure(dpi=150)
Freq = np.linspace(7,11,5)
plt.plot(Freq, V_ISHE, label=r"V$_{ISHE}$")
plt.plot(Freq, V_AHE, label=r"V$_{AHE}$")
plt.legend()
plt.savefig("Voltage_Freq_Dependence.png", dpi=300)
$f = \frac{ge}{4\pi m} \sqrt{B(B+\mu_{0}M)}$
plt.figure()
plt.plot(H_FMR)
def residual_kittel(params, x, y):
g = params['g'].value
M = params['M'].value
model = g*13991643348.73805*np.sqrt(x*(x+M))*0.0001
return np.sqrt((y-model)**2)
def fit_data_kittel(params, x):
g = params['g'].value
M = params['M'].value
model = g*13991643348.73805*np.sqrt(x*(x+M))*0.0001
return model
params = lmfit.Parameters()
params.add('g', value=2)
params.add('M', value=500)
Freq = np.linspace(7,11,5) * 1E9
B = np.array(H_FMR)
out = lmfit.minimize(residual_kittel, params, args=(B,Freq))
out.params
H_FMR
plt.figure(dpi = 150)
plt.plot(B,Freq/1E9, label="Exp. data")
plt.plot(B,fit_data_kittel(out.params,H_FMR)/1E9, label="Fitting data")
plt.title("Kittel Formula Fitting")
plt.text(1300,7.5,r"g factor: {:.3f}".format(out.params["g"].value))
plt.text(1300,7,r"M$_{sat}$"+": {:.3f} G".format(out.params["M"].value))
plt.ylabel("Microwave Frequency (GHz)")
plt.xlabel("Resonance Field (Guass)")
plt.legend()
filename = ["20200324__7GHz_301pts_avg 10counts_{}dBm_withAMP_IFBW10_S21_Pt-Py_Volt_modified.txt".format(i) for i in range(2,-18,-2)]
filename[1].split("_")[5]
linewidth = []
V_ISHE = []
H_FMR = []
V_AHE = []
for file in filename:
data = pd.read_csv(file, sep='\t')
x = data["Field (G)"].values
y = data["Voltage R (V)"].values * 1E6
params = lmfit.Parameters()
params.add('const', value= 0)
params.add('slope', value=0)
params.add('c', value=0)
params.add('A',value=0)
params.add('B',value=0)
params.add('T', value=40)
params.add('Hfmr', value=600)
out = lmfit.minimize(residual, params, args=(x,y))
plt.figure(dpi=150)
plt.plot(x,y, label = "original Voltage R")
plt.plot(x, fit_data(out.params,x), label = "fitting data")
plt.text(1500,2.5,r"V$_{ISHE}$: " + "{:.3f}".format(out.params["A"].value))
V_ISHE.append(out.params["A"].value)
plt.text(1500,2,r"V$_{AHE}$: " + "{:.3f}".format(out.params["B"].value))
V_AHE.append(out.params["B"].value)
plt.text(1500,1.5,r"H$_{FMR}$: "+"{:.3f}".format(out.params["Hfmr"].value))
H_FMR.append(out.params["Hfmr"].value)
plt.text(1500,1,r"Linewidth: {:.3f}".format(np.abs(out.params["T"].value)))
linewidth.append(np.abs(out.params["T"].value))
plt.ylim(-0.1,5)
plt.legend()
plt.xlabel("Field (G)")
plt.ylabel(r"Voltage ($\mu$V)")
plt.title("NA Power "+ file.split("_")[5])
plt.savefig("NA_Power_"+ file.split("_")[5]+".png", dpi =300)
Power = np.linspace(2,-16,len(V_ISHE))
plt.figure(dpi=150)
plt.plot(10**((Power+20)/10),V_ISHE)
plt.title(r"V$_{ISHE}$ Power Dependence")
plt.xlabel("Power after amp. (mW)")
plt.ylabel(r"Fitting V$_{ISHE}$ ($\mu$V)")
plt.text(7,3.7,"The x axis is a approximation.\n It assume the amplifier has linear gain (20 dB).")
plt.savefig("V_ISHE_power_dependence.png",dpi=300)
Power = np.linspace(2,-16,len(V_AHE))
plt.figure(dpi=150)
plt.plot(10**((Power+20)/10),V_AHE)
plt.title(r"V$_{AHE}$ Power Dependence")
plt.xlabel("Power after amp. (mW)")
plt.ylabel(r"Fitting V$_{AHE}$ ($\mu$V)")
plt.text(7,0.043,"The x axis is a approximation.\n It assume the amplifier has linear gain (20 dB).")
plt.savefig("V_AHE_power_dependence.png",dpi=300)